package com.sanlunche.blog.controller;

import com.sanlunche.blog.pojo.Emp;
import com.sanlunche.blog.pojo.Result;
import com.sanlunche.blog.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {

    @Autowired
    private UserServiceImpl userService;

    @PostMapping("/login")
    public Result LoginCheck(@RequestBody Emp emp){
        log.info("登录系统运行。。。username ={},password = {}",emp.getUsername(),emp.getPassword());
        Emp e = userService.login(emp);
        return e != null? Result.success(e):Result.error("用户名或密码错误");
    }

}
